<?php
class AllAdsPart extends Part {
	private $data;
	public function __construct ($data) {
		$this->data = $data;
		if(!is_array($data)) {
			$this->data = array();
		}
		parent::__construct();
	}
	protected function generateHTML () {
		$this->html .= '<div id="adList">';
		$l = count($this->data);
		for($i=0; $i<$l; $i++) {
			$this->html .= $this->singleAd($i);
		}
		$this->html .= '</div>';
	}
	private function singleAd ($number) {
		//$log = new Log('AllAdsPart::singleAd');
		$output = "\n".'<div class="ad">';
		$output .= "\n\t".'<div class="title">'.$this->data[$number]['title'].'</div>';
		$output .= "\n\t".'<div class="description">'.$this->data[$number]['description'].'</div>';
		$output .= "\n".'</div>';
		//$log->add('pojedyncze ogłoszenie: <br /><textarea>'.$output.'</textarea>');
		return $output;
	}
}
?>